<?php
/**
 * Created by PhpStorm.
 * User: 10037
 * Date: 2022/6/14
 * Time: 22:14
 */

namespace app\index\controller;




use app\index\model\Backlinks;
use app\index\model\Essaytable;
use app\index\model\Message;

class HomeInfo
{
    public function selectHomeInfo()
    {

        $back = new Backlinks();
        $essay = new Essaytable();
        $backAll = $back->selectAllInfo();

        $essayAll = $essay->selectAllInfo();
        return json([
            'backAll' => $backAll,
            'essayAll' => $essayAll
        ]);
    }

    public function addMessage($text){
       $ip= $_SERVER["REMOTE_ADDR"];
       $mess=new Message();
       $result= $mess->selectIp($ip);
       if($result===1){
           return json([
               'status'=>200,
               'message'=>'您已经留下过意见！'
           ]);
       }

       $mess->addMessage($ip,$text);

       return json([
           'status'=>200,
           'message'=>'提交成功，博主会尽量的去采纳您的意见'
       ]);
    }
}